/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cassys.delegates;

import cassys.dataaccess.DAOException;
import cassys.servicelocator.ServiceLocator;
import java.rmi.RemoteException;
import java.util.ArrayList;
import cassys.datatransferobjects.UserDTO;
import cassys.ejb.sessionbean.UserBeanRemote;

/**
 *
 * @author ASUS
 */
public class UserDelegate {

    private UserBeanRemote userBean = null;

    public UserDelegate() {
        userBean = ServiceLocator.getInstance().lookupUserBean();
    }

    public ArrayList<UserDTO> findAllUsers() throws DAOException, RemoteException {
        ArrayList<UserDTO> list = (ArrayList<UserDTO>) userBean.findAllUsers();
        return list;
    }

    public UserDTO findUser(String userId) throws DAOException, RemoteException {
        System.out.println("UserDeleage FindUser");
        return userBean.findUser(userId);
    }

    public UserDTO findUserByName(String username) throws DAOException, RemoteException {
        System.out.println("UserDeleage FindUser");
        return userBean.findUserByName(username);
    }

    public void updateUser(UserDTO user) throws DAOException, RemoteException {
        userBean.updateUser(user);
    }

    public void insertUser(UserDTO user) throws DAOException, RemoteException {
        userBean.insertUser(user);
    }

    public void deleteUser(UserDTO user) throws DAOException, RemoteException {
        userBean.deleteUser(user);
    }

    public boolean userValidate(String username, String password) throws DAOException, RemoteException {
        return (userBean.userValidate(username.trim(), password.trim()));
    }

    public boolean isRoleAdmin(String userid) throws DAOException, RemoteException {
        return userBean.isRoleAdmin(userid);
    }
}
